package com.demo2do.boyle.backend.web.controller.report;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.demo2do.boyle.backend.service.advertisement.AdvertisementService;
import com.demo2do.boyle.common.entity.advertisement.Advertisement;
import com.demo2do.boyle.common.entity.advertisement.Status;
import com.demo2do.core.web.interceptor.MenuSetting;
import com.demo2do.core.web.resolver.Page;

/**
 * 
 * @author Jason.Y
 *
 */
@Controller
@RequestMapping("/reports")
@MenuSetting("menu-report")
public class ReportStatisticsController {
	
	@Autowired
	private AdvertisementService advertisementService;
    
    /**
     * customer statistical
     * 
     * @return user statistical report
     */
    @RequestMapping(value= "/statistics")
    @MenuSetting("submenu-report-statistics")
    public ModelAndView list(@RequestParam(value = "status",required = false) Status status ,Page page) {
    	
    	ModelAndView modelAndView = new ModelAndView("report/report-aduser-staitschart");
        
        List<Advertisement> advertisements = advertisementService.list(status, page);
        int count = advertisementService.count(status);
    	
        modelAndView.addObject("advertisements", advertisements);
        modelAndView.addObject("count", count);
        modelAndView.addObject("status", status);
        
        return modelAndView;
    }
    
}
